package com.labyrinth.core;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;

public class SpriteObject
{
	private final Texture texture;
	private final Sprite sprite;
	private final SpriteBatch batch;

	public SpriteObject(String texturePath, float x, float y)
	{
		batch = new SpriteBatch();
		texture = new Texture(Gdx.files.internal(texturePath));
		sprite = new Sprite(texture);
		sprite.setPosition(x - texture.getHeight() / 2, y - texture.getWidth() / 2);
		sprite.setRotation(0);
		sprite.setScale(1);
	}

	public void setPosition(float x, float y)
	{
		sprite.setPosition(x - texture.getHeight() / 2, y - texture.getWidth() / 2);
	}

	public void rotate(int r)
	{
		sprite.rotate(-90 * r);
	}

	public void draw()
	{
		batch.begin();
		sprite.draw(batch);
		batch.end();
	}
}
